﻿using B.S.Procurement.Error;
using B.S.Procurement.Write.Api.Application.Command.VendorModelCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Procurement.Write.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class VendorController : ControllerBase
    {
        private readonly IMediator mediator;

        public VendorController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 添加供应商信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateVendorModel(CreateVendorModelCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 删除供应商信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> DelVendorModel(DelVendorModelCommand request)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 修改供应商信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> UpdVendorModel(UpdVendorModelCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
